//
//  ZXFDYWCView.m
//  SanYiTeaching
//
//  Created by 李文强 on 2019/4/19.
//  Copyright © 2019 SanYi. All rights reserved.
//

#import "ZXFDYWCView.h"
#import "SYFDYWCCollectionViewCell.h"

#define CellSP 20*fw
#define CellW 80*fw
@interface ZXFDYWCView ()

@property (strong, nonatomic) NSMutableArray *dataArr;

@property (strong, nonatomic) SYNoLabel *nolab;

@end

@implementation ZXFDYWCView

static NSString * const reuseIdentifier = @"Cell";

- (void)viewDidLoad {
    [super viewDidLoad];
    // Uncomment the following line to preserve selection between presentations
    // self.clearsSelectionOnViewWillAppear = NO;
    
    // Register cell classes
//    [self.collectionView registerClass:[ZXFDYWCCell class] forCellWithReuseIdentifier:reuseIdentifier];
    
    [self.collectionView registerNib:[UINib nibWithNibName:@"SYFDYWCCollectionViewCell" bundle:nil] forCellWithReuseIdentifier:@"SYFDYWCCollectionViewCell"];
    
    self.collectionView.backgroundColor = [UIColor whiteColor];
    // Do any additional setup after loading the view.
    _nolab = [[SYNoLabel alloc] initWithNameStr:@"" contView:self.view];
    [_nolab mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.view.mas_top).offset(0);
        make.left.equalTo(self.view.mas_left).offset(0);
        make.right.bottom.equalTo(self.view).offset(0);
        //        make.width.mas_equalTo(320);
        //        make.height.mas_equalTo(540);
    }];
//    _nolab.backgroundColor = [UIColor redColor];
}
- (void)requestData:(NSMutableArray *)dataListArr {
    self.dataArr = dataListArr;
    if (dataListArr.count == 0) {
        //TOP
        self.collectionView.hidden = YES;
        self.nolab.hidden = NO;
    } else {
        self.collectionView.hidden = NO;
        self.nolab.hidden = YES;
    }
    
    [self.collectionView reloadData];
}

#pragma mark <UICollectionViewDataSource>

- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
    
    return 1;
}


- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
//    return 1;
    //TOP
    return self.dataArr.count;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    SYFDYWCCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"SYFDYWCCollectionViewCell" forIndexPath:indexPath];
    SYZaiXianFuDaoModel *zxfd = self.dataArr[indexPath.row];
    cell.biaotiLab.text = zxfd.title;
    
    cell.fudaoTypeLab.text = SYStringWithPickFormat(@"辅导类型:", zxfd.typeName);
    cell.fudaoTypeLab.attributedText = [PublickFunctionObject getPriceAttribute:cell.fudaoTypeLab.text and:[UIColor redColor] andChangeBenginString:@":" andEndString:@"" andSize:12];
    cell.banjiNameLab.text = SYStringWithPickFormat(@"班级名称:", zxfd.className);
    cell.laoshiNameLab.text = SYStringWithPickFormat(@"教师名字:", zxfd.accountName);
    cell.xueshengNumberLab.text = SYStringWithPickFormat(@"学生数量:", zxfd.studentNums);
    cell.wanchengLab.text = SYStringWithPickFormat(@"完成时间:", zxfd.endDate);
    cell.canyulvLab.text = [NSString stringWithFormat:@"参与辅导%@次 评价%@人",zxfd.activeNums,zxfd.evaluateNums];
    NSString *imageNameStr = nil;
    if ([zxfd.tutorType integerValue] == 0) {
        //互动课堂
        imageNameStr = @"fudao_weiwancheng_banban";
    } else if ([zxfd.tutorType integerValue] == 1) {
        //群聊
        imageNameStr = @"fudao_weiwancheng_qunliao";
    } else {
        //单聊
        imageNameStr = @"fudao_weiwancheng_danliao";
    }
    cell.typeLab.image = [UIImage imageNamed:imageNameStr];
    
//    //TOP
//    SYZaiXianFuDaoModel *zxfd = self.dataArr[indexPath.row];
//    cell.titleLabel.text = zxfd.title;
//    NSString *typeName = SYStringWithPickFormat(@"辅导类型：", zxfd.typeName);
//    cell.fuDaoLeiXingLabel.attributedText = [PublickFunctionObject getPriceAttribute:typeName and:[UIColor redColor] andChangeBenginString:@"：" andEndString:@"" andSize:12];
//    NSString *accountName = SYStringWithPickFormat(@"老师姓名：", zxfd.accountName);
//    cell.mentorLabel.attributedText = [PublickFunctionObject getPriceAttribute:accountName and:[UIColor redColor] andChangeBenginString:@"：" andEndString:@"" andSize:12];
//
//    cell.jieZhiRiQiLabel.text = SYStringWithPickFormat(@"截止日期：", zxfd.endDate);
//    cell.fuDaoCeShuLabel.text = SYStringWithPickFormat(@"辅导次数：", zxfd.tutorTimes);
//    NSString *stuStr = SYStringWithPickFormat(@"学生数量：", zxfd.studentNums);//缺少学生数量。接口
//    cell.xueShengNumLabel.attributedText = [PublickFunctionObject getPriceAttribute:stuStr and:[UIColor redColor] andChangeBenginString:@"：" andEndString:@"" andSize:12];
//    cell.keMuLable.text = SYStringWithPickFormat(@"完成日期：", zxfd.createDate);
    
    return cell;
}
#pragma mark == collectionViewDelegate
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
    
    //top, left, bottom, right
    return CGSizeMake(318*fw, 230*fh);
}
- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section{
    //top, left, bottom, right
    if (_Type == YES) {
        return UIEdgeInsetsMake(20, CellSP, 20,CellSP);
    }else{
        return UIEdgeInsetsMake(CellSP, CellW, CellSP,CellW);
    }
    
}
#pragma mark <UICollectionViewDelegate>

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
    SYZaiXianFuDaoModel *zxfd = self.dataArr[indexPath.row];
    [self.delegate complateLeaveForClassDetailView:zxfd];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/


#pragma mark <UICollectionViewDelegate>

/*
// Uncomment this method to specify if the specified item should be highlighted during tracking
- (BOOL)collectionView:(UICollectionView *)collectionView shouldHighlightItemAtIndexPath:(NSIndexPath *)indexPath {
	return YES;
}
*/

/*
// Uncomment this method to specify if the specified item should be selected
- (BOOL)collectionView:(UICollectionView *)collectionView shouldSelectItemAtIndexPath:(NSIndexPath *)indexPath {
    return YES;
}
*/

/*
// Uncomment these methods to specify if an action menu should be displayed for the specified item, and react to actions performed on the item
- (BOOL)collectionView:(UICollectionView *)collectionView shouldShowMenuForItemAtIndexPath:(NSIndexPath *)indexPath {
	return NO;
}

- (BOOL)collectionView:(UICollectionView *)collectionView canPerformAction:(SEL)action forItemAtIndexPath:(NSIndexPath *)indexPath withSender:(id)sender {
	return NO;
}

- (void)collectionView:(UICollectionView *)collectionView performAction:(SEL)action forItemAtIndexPath:(NSIndexPath *)indexPath withSender:(id)sender {
	
}
*/

@end
